/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sisgea.conexaobd;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Lau
 */
public class ConexaoPost {
    
    Connection con;
    
    /** Creates a new instance of AcessoMySql */
    public ConexaoPost() {
    }
    
    public Connection conectar(){
        String login ="postgres";
		String senha ="1234SERvi";
		String nomeBanco ="BH";
		String driver ="org.postgresql.Driver";
                String servi = "hq-con-dc-01";
        try {
            Class.forName("com.mysql.jdbc.Driver");
           //con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/sisvenda?user=root&password=");
            con = DriverManager.getConnection("jdbc:postgresql://"+servi+":5432/"+nomeBanco+"?user="+login+"&"+senha+"=");
           // con = DriverManager.getConnection("jdbc:postgresql://"+servi+":5432/"+nomeBanco");
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
            System.out.println("Não foi possível encontrar o Driver!");
        } catch (SQLException ex) {
            ex.printStackTrace();
            System.out.println("Não foi possível conectar ao banco!");
        }
        return con;
    }
    
    public void desconectar(){
        try {
            con.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
}
    

